package com.lmt_11;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;

public class MapTest2 {
    public static void main(String[] args) {
        Map<String,Double> map = new HashMap<>();
        map.put("jjj",12.5);
        map.put("ewr",135.2);
        map.put("ds",78.5);
        map.put("fs",8.2);
        Set<String> set = map.keySet(); // 用一个set集合获取键
        for (String s : set) {
            System.out.println(map.get(s));
        }
        // 键值对方式遍历 先将map转换成entry
        for (Map.Entry<String, Double> stringDoubleEntry : map.entrySet()) {
            System.out.println(stringDoubleEntry);
        }

        map.forEach(new BiConsumer<String, Double>() {
            @Override
            public void accept(String s, Double aDouble) {
                System.out.println(s+"==>"+aDouble);
            }
        });
        map.forEach(( s,aDouble)-> System.out.println(s+"==>"+aDouble));
    }
}
